<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/plug/Hui-iconfont/1.0.8/iconfont.min.css" />
<style type="text/css">
.row {
	margin-top: 15px
}
</style>
</head>
<body>
	<div class="panel panel-default">
		<input type="hidden" value="${scenicSpotId}" id="scenicSpotId"></input> 
		<input type="hidden" value="${hardwareInfo.id}" id="id"></input>
		<div class="panel-body">
			<form id="dataForm">
				<div class="row cl">
					<label class="form-label col-xs-2"><span class="c-red">*</span>设备名称：</label>
					<div class="form-label col-xs-4">
						<input class="input-text required" type="text" value="${hardwareInfo.name}" id="name"></input>
					</div>
				</div>
				<div class="row cl" style="text-align: center">
					<button id="saveOrUpdate" class="btn btn-secondary radius size-L" type="button">保存</button>
					<button id="cancelBtn" class="btn btn-secondary radius size-L" type="button">取消</button>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript" src="${ctx}/static/plug/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript">
		var canSubmit = true;
		$(function() {
			$("#saveOrUpdate").click(function() {
				if(!$("#dataForm").valid()) {
					return;
				}
				var id = $("#id").val();
				var tips = "";
				if (id == null || id == '') {
					tips = "新增";
				} else {
					tips = "修改";
				}
				if(canSubmit) {
					canSubmit = false;
					var updateData = new Object();
					updateData.name = $("#name").val();
					updateData.id = $("#id").val();
					updateData.scenicSpotId = $("#scenicSpotId").val();
					$.post("${ctx}/hardwareInfo/saveOrUpdate", updateData, function(data) {
						canSubmit = true;
						if (data.result) {
							layer.confirm(tips + '成功!', {
								btn : [ '确定' ]
							}, function() {
								var index = parent.layer.getFrameIndex(window.name);
								parent.reloadData();
								parent.layer.close(index);
							});
						} else {
							layer.confirm(tips + "失败!" + data.errorMsg, {
								btn : [ '确定' ]
							}, function() {
								var index = parent.layer.getFrameIndex(window.name);
								parent.layer.close(index);
							});
						}
					});
				}
			});

			$("#cancelBtn").click(function() {
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
			});
		});
	</script>
</body>
</html>
